package com.runfig;

import com.runfig.figautowrite.controller.FigController;
import com.runfig.figfactorybean.Dog;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.stream.Stream;

public class MyTest {



    @Test
    public void test2() {

//        ArrayList<String> strings = new ArrayList<>();
//        strings.add("a");
//        strings.add("b");
//        strings.add("c");
//        strings.add("d");
//        Iterator<String> iterator = strings.iterator();
//        while (iterator.hasNext()) {
//            String next = iterator.next();
//            if(next.equals("b")){
//                strings.add("e");
//            }
//        }


        Dog dog = new Dog();
        dog.setName("a");

        if (dog.getName().equals("b")) {
            System.out.println("nnbb");
        }

        for (int i = 0; i < 300; i++) {
            if (i == 99) {
                System.out.println("dd");
            } else {
                System.out.println("]]]");
            }

        }

//           int num = 1;
//
//           if (num == 2) {
//               System.out.println("ddd");
//           }

//        num  = 2;
//        num = add(num);
//        System.out.println(num);
//        num = 3;
//        System.out.println(num);
    }

    static int add(int i) {
        return i+100;
    }

    @Test
    public void test() {
        FigController figController = new FigController();
        Class<? extends FigController> aClass = figController.getClass();
        Stream.of(aClass.getDeclaredFields()).forEach((field -> {
            FigAutoWried figAutoWried = field.getAnnotation(FigAutoWried.class);
            if (figAutoWried != null) {
                field.setAccessible(true);
                Class<?> type = field.getType();
                Object o = null;
                try {
                    o = type.newInstance();
                    field.set(figController, o);
                } catch (InstantiationException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                } finally {
                }
            }
        }));
        System.out.println(figController.getFigService());
    }
}
